<template>
    <div class="wy-main business-car-manage">
     <a-row class="wy-main-title">
       <a-col :span="24">
				<p class="title-p">
					<a-divider class="title-vertical"  type="vertical" />
					<span class="title-span" >招标项目审核</span>
					<a-divider class="title-divider"  />
				</p>
			</a-col>
	 </a-row>
     <div class="my-main-cont">
         <a-input  placeholder="请输入招标标题" v-model="tendTitle" style="width: 200px"/>
         <a-button type="primary" style="margin-left: 10px;" @click="gettenderinginfo">查询</a-button>
			   <a-button style="margin-left: 10px;" @click="react">重置</a-button>
         <a-button class="title-button" type="primary" style="float: right" @click="seeAllInfo()">批量审核</a-button>
         <a-table :columns="columns" :rowKey="record => record.tendId" :dataSource="data" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :pagination="pagination" :loading="loading" style="margin-top: 20px" >
           <span slot="name" slot-scope="text1">
				     <span>{{text1.address1}}--→{{text1.address2}}</span>
			     </span>
           <!-- <span slot="attestationStatus" slot-scope="text, record">
             <span v-if="record.attestationStatus==0">未认证</span>
             <span v-if="record.attestationStatus==1">认证中</span>
						 <span v-if="record.attestationStatus==2">已认证</span>
           </span>
            <span slot="bidResult" slot-scope="text, record">
             <span v-if="record.bidResult==0">未中标</span>
             <span v-if="record.bidResult==1">中标</span>
           </span> -->
             <span slot="operation" slot-scope="text, record">

                <a href="javascript:;" v-if="record.approvalStatus==0" @click="seeInfo(record)">待审核</a>
                <a href="javascript:;" v-if="record.approvalStatus==1" @click="seeInfo(record)">审核通过</a>
						    <a href="javascript:;" v-if="record.approvalStatus==2" @click="seeInfo(record)">审核失败</a>
                <a href="javascript:;" @click='delDriver(record)'>删除</a>
		         </span>
         </a-table>
          <div style="margin-top: -50px">
            <!-- <a-button>选择全部</a-button>
            <a-button>反向选择</a-button>
            <a-button>清除选择</a-button> -->
            <a-button @click="delAll">删除所选</a-button>
          </div>
					<a-modal title="招标项目审核" :visible="visible"  @cancel="handleCancel"  width="900px" :maskClosable='false' :footer="null" >
		       <publish-add v-if="visible" @cancel="handleCancel" :datail='datail'></publish-add>
		      </a-modal>
          <a-modal title="招标项目审核" :visible="visibleAll"  @cancel="handleCancel"  width="900px" :maskClosable='false' :footer="null" >
           <publish-add-all v-if="visibleAll" @cancel="handleCancel" :datailAll='datailAll'></publish-add-all>
          </a-modal>
     </div>
		 
    </div>
</template>
<script>
import publishAdd  from './Publish'
import publishAddAll  from './PublishAll'
const columns = [{
		title: '招标标题',
		dataIndex: 'tendTitle',
		key: 'tendTitle',
		scopedSlots: {
			customRender: 'tendTitle'
		},
	}, {
		title: '出发地-到达地',
		dataIndex: 'fromCity',
		key: 'fromCity'
	}, {
		title: '发布日期',
		key: 'createTime',
		dataIndex: 'createTime',
	}, {
			title: '操作',
			key: 'operation',
			scopedSlots: {
				customRender: 'operation'
			},
		}];
// const rowSelection = {
//   onChange: (selectedRowKeys, selectedRows) => {
//     console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
// //   },
// //   onSelect: (record, selected, selectedRows) => {
// //     console.log(record, selected, selectedRows);
// //   },
// //   onSelectAll: (selected, selectedRows, changeRows) => {
// //     console.log(selected, selectedRows, changeRows);
//   },
// };
export default {
    
    data() {
        return {
				 datail: {},
         datailAll:{},
         tendTitle: '',
         data:[],
         visible: false,
         visibleAll:false,
         loading: false,
         columns,
         // rowSelection,
          selectedRowKeys: [],
         	pagination: {
          ageSizeOptions: ['10', '20', '30', '40', '100'],
				  defaultCurrent: 1,
				  defaultPageSize: 10,
				  showSizeChanger: true,
          total:0,
				  showTotal: (total, range) => `共 ${total} 条记录 `
				},
        }
    }, 
    created() {
      this.gettenderinginfo()
		},
		components: {
			publishAdd,
      publishAddAll
		},
    methods: {


			// 审核线路信息
			seeInfo(data){
				this.visible = true
		    this.datail = data
			},
      seeAllInfo(){
        if(this.selectedRowKeys.length){
            this.visibleAll = true;
            let logIds = [];
           for(var i=0;i<this.selectedRowKeys.length;i++){
            logIds.push({"tendId":this.selectedRowKeys[i]})
           }
            this.datailAll = logIds;
          }else{
            this.$message.success('请选择需要审核的招标项目!')
          }
      
      },
			//关闭弹框

			handleCancel(){
			this.visible = false
      this.visibleAll = false
      this.gettenderinginfo();
      this.selectedRowKeys=[];
			},
			//删除
      delAll() {
        this.$confirm({
					title: '确定删除所选中的记录？',
					content: '当您点击确定按钮后，这些记录将会被彻底删除',
					centered: true
				})
      },
      onSelectChange (selectedRowKeys) {
          console.log('selectedRowKeys changed: ', selectedRowKeys);
          this.selectedRowKeys = selectedRowKeys
        },
			//审核
            // 删除单条信息
      delDriver(data){
        console.log(data)
        let that = this
        this.$confirm({
          title: '确定删除所选中的记录?',
          content: '当您点击确定按钮后，这些记录将会被彻底删除',
          centered: true,
          onOk () {
            let logIds = []
            logIds.push(data.tendId)
            that.$delete('/info/logisticsTenderee/' + logIds.join(',')).then(() => {
              that.$message.success('删除成功')
              that.selectedRowKeys = []
              that.gettenderinginfo()
            })
          },
          onCancel () {
            that.selectedRowKeys = []
          }
        })
      },
		
      //重置
      react() {
        this.tendTitle = ''
        this.defaultCurrent = 1
        this.gettenderinginfo()
      },
      // 获取招标信息
			gettenderinginfo(params={}){
				this.loading = true
				params.tendTitle = this.tendTitle
				params.pageSize = this.pagination.defaultPageSize
				params.pageNum = this.pagination.defaultCurrent
				this.$get('/info/logisticsTenderee', params).then((r) => {
					this.loading = false
					console.log(r)
					this.data = r.data.data.rows
					this.pagination.total = r.data.data.total
				})
			},

    }
}
</script>
<style lang="less">

</style>
